<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
    <button class="btn">点击</button>

</body>
<script type="text/javascript">
    document.querySelector(".btn").addEventListener("click",function () {
        console.log("刚才有人点击。。。")
    },false);

    /**
     * 创建对象浏览器默认封装的事件blur() 和 click()
     */
    var elementDiv = document.createElement("div");
    elementDiv.blur();//相当于触发div对象的onblur事件
    elementDiv.click();//相当于触发div对象的onclick事件

    /**
     * 创建事件对象
     * document.createEvent(DOM事件类型)
     *
     * 参数               事件接口           初始化方法
     * HTMLEvents       HTMLEvents         initEvent("字符串值。事件的类型。",事件是否起泡。,是否可以用 preventDefault() 方法取消事件。)
     * MouseEvents      MouseEvents        initMouseEvent()
     * UIEvents         UIEvents           initUIEvent()
     *
     * HTMLEvents：包括 ‘abort’, ‘blur’, ‘change’, ‘error’, ‘focus’, ‘load’, ‘reset’, ‘resize’, ‘scroll’, ‘select’,‘submit’, ‘unload’
     *
     * UIEevents ：包括 ‘DOMActivate’, ‘DOMFocusIn’, ‘DOMFocusOut’, ‘keydown’, ‘keypress’, ‘keyup’.间接包含 MouseEvents
     *
     * MouseEvents：包括 ‘click’, ‘mousedown’, ‘mousemove’, ‘mouseout’, ‘mouseover’, ‘mouseup’
     */
    var MouseEvent = document.createEvent("MouseEvents");
    MouseEvent.initMouseEvent("click",false,true);
    document.querySelector(".btn").dispatchEvent(MouseEvent);

</script>
</html>